<?php 
$source = imagecreatefromjpeg($_GET["src"]);
$sourceWidth = imagesx($source);
$sourceHeight = imagesy($source);

$thumbWidth = $_GET["w"];
$thumbHeight = ceil($sourceHeight * $thumbWidth / $sourceWidth);
$image = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($image, $source, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $sourceWidth, $sourceHeight);

header("content-type: image/jpeg");
imagejpeg($image, null, 100);
?> 
